<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<link rel="stylesheet" type="text/css" href="/css/validator.css"/>
<link rel="Stylesheet" type="text/css" href="/css/jHtmlArea.css" />
<link rel="stylesheet" type="text/css" href="/css/jHtmlArea.ColorPickerMenu.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
<link href="/css/ddaccordion.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css" media="screen">
 <!-- 
  SELECT.selCont{ margin: 10px; width: 200px; }
  div.jHtmlArea { border: solid 1px #ccc; }
  -->
</style> 
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
<!-- 验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/formValidator_min.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidator.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidatorRegex.js" charset="UTF-8"></script>
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>	
<script type="text/javascript" src="/js/jHtmlArea-0.6.0.js"></script>
<script src="/js/jHtmlArea.ColorPickerMenu-0.6.0.min.js"></script>
<script src="/js/grid.locale-en.js" type="text/javascript"></script>
<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
<s:url var="supplierPops" value="/json/supplierPops.do"/>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<script language="javascript">
	$().ready( function() {
		if($("#menuKey").val()==""){
			$("#saveOrdUpdate").val('save');
			$('#menuKey').attr("readonly", false);
			$("input[name='optionCode']").each(function(i,item){
				$(this).attr("readonly", false);
			});
		}else{
			$("#saveOrdUpdate").val('update');
			$('#menuKey').attr("readonly", true);
			$("input[name='optionCode']").each(function(i,item){
				if(item.value !=''){
					$(this).attr("readonly", true);
				}
			});
		}

		$("input[name='optionSortOrder']").each(function(i,item){
			$(this).numeric();
		});


		$("#newOpn").click(function() {
			var sOpt="<tr class=''>"+
    		"<td><input type='hidden' size='10' name='optionId' id='optionId' value='' /></td>"+
			"<td><input type='text' size='10' name='optionCode' id='optionCode' value=''/></td>"+
			"<td><input type='text' size='6' name='optionMemoOne' id='optionMemoOne' value='' /></td>"+
			"<td><input type='text' size='6' name='optionMemoTwo' id='optionMemoTwo' value='' /></td>"+
			"<td><input type='text' name='optionName' id='optionName' value='' /></td>"+
			"<td><input type='text' size='4' name='optionSortOrder' id='optionSortOrder' value='' /></td>"+
			"</tr>";
			$("#addOption").append(sOpt);
		});
		
		$("#submit_button").click(function(){
			try {
				$("input[name='optionSortOrder']").each(function(i,item){
					if($("input[id='optionCode_"+(i+1)+"']").val()!=""&&item.value==""){
						if(!($("input[id='optionCode_"+(i+1)+"']").val()===undefined)){
							alert("SortOrder为必填");
							throw item;
						}
					}
					//if($("#optionCode").val()!=""&&item.value==""){
					//	alert("optionCode和SortOrder为必填");
					//	throw item;
					//}
				});
			}catch(e){
				return false;
			}
			$("#menuForm").submit();
		});

});
</script>	
	    
<h1>选单维护管理 <br/>
<div class="f-link">
	<yaodian100:checkPermission permissions="GROUP_A-50-100-100"><a href="${midContextPath}/menu/list.do">回选单维护列表页</a></yaodian100:checkPermission>
	<yaodian100:checkPermission permissions="ROLE_MENUCODE"><a href="${midContextPath}/menu/listYekmobile.do">耶客手机维护</a></yaodian100:checkPermission>
	<a href="http://10.0.1.1/jinwei/menuInit.html" target="_blank">更新menu(更新后请重新登入)</a>
</div>
</h1>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br/>
<s:form action="save.do" method="post" id="menuForm">
<table class="tb-data" width="100%">
		<tr><th>Menu Key</th></tr>
		<tr><td><input type="text" size="30" id="menuKey" name="menuKey" value="${menu.key}"} /></td></tr>
		<tr><th>Menu Desc</th></tr>
		<tr><td><input type="text" size="40" id="menuDesc" name="menuDesc" value="${menu.description}" /></td></tr>
		<tr><th>Menu Type</th></tr>
		<tr><td><input type="text" maxlength="1" size="1" id="menuType" name="menuType" value="${menu.type}" /></td></tr>
		<tr><th>Memo</th></tr>
		<tr><td><textarea rows="3" cols="80" id="menuMemo" name="menuMemo">${menu.memo}</textarea></td>
		<input type="hidden" id="saveOrdUpdate" name="saveOrdUpdate" value=""/>
		</tr>
</table>
<table class="tb-data" width="100%">	
	 <thead>                   
	   <tr>
	       <th></th>
	       <th>OPTION CODE</th>
	       <th>OPTION MEMO1</th>
	       <th>OPTION MEMO2</th>
	       <th>OPTION NAME</th>
	       <th>SORT ORDER</th>
	       <th>删除</th>
	   </tr>
		</thead>
	  <tbody>
			<c-rt:forEach items="${optionCodes}" var="option" varStatus="rows_index">        
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">	
					<td><input type="hidden" size="10" name="optionId" id="optionId_${rows_index.count}" value="${option.oid}" />${option.oid}</td>
					<td><input type="text" size="10" name="optionCode" id="optionCode_${rows_index.count}" value="${option.code}"/></td>
					<td><input type="text" size="6" name="optionMemoOne" id="optionMemoOne_${rows_index.count}" value="${option.memo1}" /></td>
					<td><input type="text" size="6" name="optionMemoTwo" id="optionMemoTwo_${rows_index.count}" value="${option.memo2}" /></td>
					<td><input type="text" name="optionName" id="optionName_${rows_index.count}" value="${option.name}" /></td>
					<td><input type="text" size="4" name="optionSortOrder" id="optionSortOrder_${rows_index.count}" value="${option.sortOrder}" /></td>
					<td><input name="optionDelete" type="checkbox" value="${option.code}"/></td>	
				</tr>
			</c-rt:forEach>    
			<tr class="">
		    		<td><input type="hidden" size="10" name="optionId" id="optionId" value="" /></td>
					<td><input type="text" size="10" name="optionCode" id="optionCode" value=""/></td>
					<td><input type="text" size="6" name="optionMemoOne" id="optionMemoOne" value="" /></td>
					<td><input type="text" size="6" name="optionMemoTwo" id="optionMemoTwo" value="" /></td>
					<td><input type="text" name="optionName" id="optionName" value="" /></td>
					<td><input type="text" size="4" name="optionSortOrder" id="optionSortOrder" value="" /></td>
					<td><a href="javascript:;" id="newOpn">添加新的Option</a></td>
	    	</tr> 
	  </tbody>		
	  <tbody id="addOption"></tbody>
		<tr class="">
			<td>
				<input type="button" id="submit_button" value="储存"/>
			</td>
		</tr>
	</table>
</s:form>
